/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gagnatech.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Dimitri
 */
@Entity
@Table(name = "loan")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Loan.findAll", query = "SELECT l FROM Loan l"),
    @NamedQuery(name = "Loan.findByIdloan", query = "SELECT l FROM Loan l WHERE l.idloan = :idloan"),
    @NamedQuery(name = "Loan.findByReturndate", query = "SELECT l FROM Loan l WHERE l.returndate = :returndate")})
public class Loan implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDLOAN")
    private Integer idloan;
    @Column(name = "RETURNDATE")
    @Temporal(TemporalType.DATE)
    private Date returndate;
    @JoinColumn(name = "USER_IDUSER", referencedColumnName = "IDUSER")
    @ManyToOne
    private User userIduser;
    @JoinColumn(name = "MEDIA_IDMEDIA", referencedColumnName = "IDMEDIA")
    @ManyToOne
    private Media mediaIdmedia;

    public Loan() {
    }

    public Loan(Integer idloan) {
        this.idloan = idloan;
    }

    public Integer getIdloan() {
        return idloan;
    }

    public void setIdloan(Integer idloan) {
        this.idloan = idloan;
    }

    public Date getReturndate() {
        return returndate;
    }

    public void setReturndate(Date returndate) {
        this.returndate = returndate;
    }

    public User getUserIduser() {
        return userIduser;
    }

    public void setUserIduser(User userIduser) {
        this.userIduser = userIduser;
    }

    public Media getMediaIdmedia() {
        return mediaIdmedia;
    }

    public void setMediaIdmedia(Media mediaIdmedia) {
        this.mediaIdmedia = mediaIdmedia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idloan != null ? idloan.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Loan)) {
            return false;
        }
        Loan other = (Loan) object;
        if ((this.idloan == null && other.idloan != null) || (this.idloan != null && !this.idloan.equals(other.idloan))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gagnatech.entity.Loan[ idloan=" + idloan + " ]";
    }
    
}
